home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / 3DGPL 1.0 / CODE / HARDWARE / 386-GCC / HARDWARE.H < prev   
Encoding:
C/C++ Source or Header  |  1995-06-20  |  4.7 KB  |  108 lines  |  [TEXT/MACA]

  1. #ifndef _HARDWARE_H_
  2. #define _HARDWARE_H_
  3.  
  4. /** 3DGPL *************************************************\
  5.  *  (MSDOS, i386+, VGA, DJGPP)                            *
  6.  *  Header for hardware specific stuff.                   *
  7.  *                                                        *
  8.  *  hardware.c               hardware specific stuff.     *
  9.  *                                                        *
  10.  *  (6/1995) By Sergei Savhenko. (savs@cs.mcgill.ca).     *
  11.  *  Copyright (c) 1995 Sergei Savchenko.                  * 
  12.  *  THIS SOURCE CODE CAN'T BE USED FOR COMERCIAL PURPOSES *
  13.  *  WITHOUT AUTHORISATION                                 *
  14. \**********************************************************/
  15.  
  16. typedef short signed_16_bit;                /* compiler/mashine dependent */
  17. typedef int   signed_32_bit;           
  18. typedef unsigned short unsigned_16_bit;
  19. typedef unsigned int   unsigned_32_bit;
  20.  
  21. #define HW_set_int(dst,lng,val)   asm("movl  %0,%%eax \n"             \
  22.                                       "movl  %1,%%edi \n"             \
  23.                                       "movl  %2,%%ecx \n"             \
  24.                                       "cld \n"                        \
  25.                                       "rep \n"                        \
  26.                                       "stosl %%eax,(%%edi) \n"        \
  27.                                       ::"g" (val),"g" (dst),"g" (lng) \
  28.                                       :"eax","edi","ecx"              \
  29.                                      ) 
  30.  
  31. #define HW_set_char(dst,lng,val)  asm("movb  %0,%%al  \n"             \
  32.                                       "movl  %1,%%edi \n"             \
  33.                                       "movl  %2,%%ecx \n"             \
  34.                                       "cld \n"                        \
  35.                                       "rep \n"                        \
  36.                                       "stosb %%al,(%%edi) \n"         \
  37.                                       ::"g" (val),"g" (dst),"g" (lng) \
  38.                                       :"al","edi","ecx"               \
  39.                                      ) 
  40.  
  41. #define HW_copy_int(src,dst,lng)  asm("movl  %0,%%esi \n"             \
  42.                                       "movl  %1,%%edi \n"             \
  43.                                       "movl  %2,%%ecx \n"             \
  44.                                       "cld \n"                        \
  45.                                       "rep \n"                        \
  46.                                       "movsl (%%esi),(%%edi) \n"      \
  47.                                       ::"g" (src),"g" (dst),"g" (lng) \
  48.                                       :"esi","edi","ecx"              \
  49.                                      ) 
  50.  
  51. #define HW_copy_char(src,dst,lng) asm("movl  %0,%%esi \n"             \
  52.                                       "movl  %1,%%edi \n"             \
  53.                                       "movl  %2,%%ecx \n"             \
  54.                                       "cld \n"                        \
  55.                                       "rep \n"                        \
  56.                                       "movsb (%%esi),(%%edi) \n"      \
  57.                                       ::"g" (src),"g" (dst),"g" (lng) \
  58.                                       :"esi","edi","ecx"              \
  59.                                      ) 
  60.  
  61. #define HW_SCREEN_X_SIZE         320             
  62. #define HW_SCREEN_Y_SIZE         200        /* number of pixels total */
  63.  
  64. #define HW_SCREEN_X_MAX          319
  65. #define HW_SCREEN_Y_MAX          199        /* number of maximum pixel */
  66.  
  67. #define HW_SCREEN_X_CENTRE       160 
  68. #define HW_SCREEN_Y_CENTRE       100        /* middle of the screen */
  69.  
  70. #define HW_COLOURMAP_SIZE_CHAR 64000        /* bytes in the colourmap */
  71. #define HW_COLOURMAP_SIZE_INT  16000        /* ints in the colourmap */
  72.  
  73. struct HW_colour                            /* describes colour */
  74. {
  75.  int hw_r;
  76.  int hw_g;
  77.  int hw_b;                                  /* intensity components */
  78. };
  79.  
  80. int HW_open_screen(char *display_name,
  81.                    char *screen_name, 
  82.                    struct HW_colour palette[256],
  83.                    unsigned char *colourmap
  84.                   );
  85. void HW_blit(void);
  86. void HW_close_screen(void);
  87.  
  88. #define HW_KEY_ARROW_LEFT  331
  89. #define HW_KEY_ARROW_RIGHT 333
  90. #define HW_KEY_ARROW_UP    328
  91. #define HW_KEY_ARROW_DOWN  336
  92.  
  93. #define HW_KEY_PLUS         43
  94. #define HW_KEY_MINUS        45
  95.  
  96. #define HW_KEY_ENTER        13
  97. #define HW_KEY_SPACE        32
  98. #define HW_KEY_TAB           9              /* all i can think of */ 
  99.  
  100. void HW_run_event_loop(void (*application_main)(void),
  101.                        void (*application_key_handler)(int key_code)
  102.                       );
  103. void HW_quit_event_loop(void);
  104.  
  105. /**********************************************************/
  106.  
  107. #endif
  108.